package com.leeoohoo.config;

import com.leeoohoo.base.Result;
import com.leeoohoo.error.CustomExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import reactor.core.publisher.Mono;


@Slf4j
@RestControllerAdvice
@Order(-2)
public class SecurityExceptionHandler extends CustomExceptionHandler {
    @ExceptionHandler(AccessDeniedException.class)
    @ResponseStatus(code = HttpStatus.FORBIDDEN)
    public Mono<Result> webExchangeBindException(AccessDeniedException e) {
        e.printStackTrace();
        return Mono.just(Result.fail("账号无权限"));
    }


}
